var forgetPasswordDialog;
var changeModuleDialog;

function createLoginDialog(){
	$("#loginDiv").dialog({
		autoOpen: false,
		height: 880,
		width: 350,
		modal: false,
		resizable: false,
		title: false,
		dialogClass : 'loginDialog',
		closeOnEscape : false,
		close: function(event,ui){
			window.opener = 'top';
			window.close();
			}
		});
	var numOfDialog = $(".loginDialog").length;
	if(numOfDialog > 1)
		$(".loginDialog").first().empty().remove();
	$("#loginContent").toggleClass("hide");
	$("#loginDiv").dialog('open');
}

function createforgetpasswordDialog()
{
	forgetPasswordDialog = $("#forgetPasswordDiv").dialog({
		autoOpen: false,
		height: 'auto',
		width: 400,
		modal: true,
		resizable: true,
		closeOnEscape : true,
		close: function(event,ui){
			//window.opener = 'top';
			},		
		 buttons : {
				"Get Password" : function(){
					var userName = $("#userName").val();
										
	
						$.post("forgetPassword.htm",{'userName':userName},alert("Your Password Sent to Your MailId"));							
								
								
						forgetPasswordDialog.dialog('close');
								
					},
				"Cancel" : function(){
					forgetPasswordDialog.dialog('close');
				}
				
			}	
	});
	$("#passwordContent").toggleClass("hide");
}

function forgetPassword(){
//	alert("Please contact Administrator!!\n\n dms.admin@gssltd.co.in");
//	window.opener = 'top';
//	window.close();
	if(!forgetPasswordDialog.dialog("isOpen")){
		forgetPasswordDialog.dialog('close');
	}
	forgetPasswordDialog.dialog('open');	
}

function checkBothPasswords(){
	var s3="";
	var s1= $("#newpassword").val();
	var s2= $("#cnfpassword").val();
	if(s1 != s2){
		alert("New Password should be equal to Confirm password");
		$("#newpassword").val(s3);
		$("#cnfpassword").val(s3);
	}
}

function getPassword()
{
	//alert("Your Password Will Send To Your EmailId");
	$.post('forgetPassword.htm',{data:'data'},alert("Your Password Sent to Your MailId"));
	forgetPasswordDialog.dialog('close');
}

function createChangeModuleDialog(){
	changeModuleDialog = $("#changeModule").dialog({
		autoOpen: false,
		height:300,
		width:'auto',
		modal:true,
		resizable:true,
		position:['center','center'],
		buttons:{
			/*"Change Module" : function(){
				var value = $("input:radio[name=changeModuleRadio]:checked").val();
				if(value == "Phase")
					$.post('http://192.168.2.100:8080/Phase/')
			},*/
			"Cancel" : function(){
				changeModuleDialog.dialog("close");
			}
		}
	});
}

function showChangeModuleDialog(){
	if(!changeModuleDialog.dialog("isOpen")){
		changeModuleDialog.dialog('close');
	}
	
	changeModuleDialog.dialog('open');
}

function changeModule(appId){
	$.post('changeModule.htm',{appId:appId},function(data){
		
	});
}